<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<p>需要排序的数：</p>
<input id="getNum" type="text">
<p>排序完的数：</p>
<input id="putNum">
<script>
    var new_num=prompt("输入需要排序的数：(用逗号分隔开)");
    var i=0;
    var num=new_num.split(",");
    for (var i =0;i<num.length;i++){
        num[i]=parseFloat(num[i])&&Number(num[i]);
    }
    document.getElementById("getNum").value=num;
    var flag=true;
        for(i=0;i<num.length-1;i++){
            flag=false;
            for (var j=0;j<num.length;j++){
                if(num[j-1]>num[j]){
                    var temp=num[j-1];
                    num[j-1]=num[j];
                    num[j]=temp;
                    flag=true;
                }
            }
            if(!flag){
                break;
            }
        }
    document.getElementById("putNum").value=num;
    console.log(num);
</script>
</body>
</html>